// I don't understand why it doesn't compile in my computer with the given compiler.
// There is some strange messages
// Are there really some mistakes in my syntax?

object Premiers {
def main() : Unit = {
	println(new Plop().start());
}
}

class Plop {
	var count: Int;
	def start(): Int = {
		println("--- AFFICHAGE DES NOMBRES PREMIERS DE 0 A 100 ---");
		count = 0;
		while (count < 100) {
			if (new PlusGrandDivCom().computePGDC(count, 2 * count) == 2 ) {
				println(count);
			}
			count = count+1;
		}
		return count;
	}
}

// Re-use of the class:
class PlusGrandDivCom {
def computePGDC(num1: Int, num2: Int) : Int = {
	var pgdc: Int;
	var diff: Int;

	if (num1 == num2) {
		pgdc = num1; 
	} else {
		if(num1 < num2) {
			diff = ( num2 - num1);
			num2 = diff;
		} else {
			diff = (num1 - num2);
			num1 = diff;
		}

		pgdc = diff;

		while (!(diff == 0)) {
			if (num1 < num2) {
				diff = (num2 - num1);
			} else {
				diff = (num1 - num2);
			}

			if (!(diff == 0)) {
				pgdc = diff;
			}
		}
	}
	return pgdc;
}
}
